package com.itbaizhan.zookeeper.rmi.client;
import com.itbaizhan.zookeeper.rmi.common.HellloService;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;

public class RmiClient {
    public static void main(String[] args) throws Exception {
        System.out.println("rmi client runing");
        //定义url
        String url = "rmi://localhost:1099/com.itbaizhan.zookeeper.rmi.service.HelloSreviceImpl";
        //找寻发布的服务，并返回对象
        Remote lookup = Naming.lookup(url);
        //强制类型转换
        HellloService hellloService = (HellloService)lookup;
        //调用方法
        String result = hellloService.sayHello("gtjin");
        System.out.println("client result: "+result);

    }
}
